package com.gxa.medical.common;


import lombok.Data;

//T泛型类型
@Data
public class Result<T> {

    //响应的状态0成功，其他失败
    private  Integer code;
    //提示信息
    private  String msg;
    //返回的数据
    private T data;
    //返回总记录数
    private Long count;
//构建带分页的成功
    public static Result buildSuccess(Object data,Long count){
        Result result=new Result();
        result.setCode(0);
        result.setMsg("请求成功!");
        result.setData(data);
        result.setCount(count);
        return result;
    }



    public static Result buildSuccess(Object data){
        Result result=new Result();
        result.setCode(0);
        result.setMsg("请求成功!");
        result.setData(data);
        return result;
    }


    public static Result buildSuccess(){

        return buildSuccess(null);
    }

    public static Result buildFail(String msg,Integer code){
        Result result=new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

}
